package com.exercise;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class exercise03 {
    public static void main(String[] args) {
        String str = "fjekwFDQFjfeAFEajfeo2FAFEjfew";
        Map<Character, Integer> hashMap = new HashMap<Character, Integer>();

        for (int i = 0; i < str.length(); i++) {
            char key = str.charAt(i);
            if(hashMap.containsKey(key)){
                int value = hashMap.get(key);
                value += 1;
                hashMap.put(key, value);
            }else{
                hashMap.put(key,1);
            }
        }
        System.out.println(hashMap);
        Set<Character> keys = hashMap.keySet();
        for(Character key : keys){
            System.out.println(key + "出现了" + hashMap.get(key) + "次");
        }
    }
}
